<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Product_category_model  extends MY_Model  {

    public $table = 'product_category_mn';

	public function __construct() {
		$this->class_name = get_class ( $this );
		parent::__construct( $this->class_name, $this->table );
		parent::init( $this->class_name, $this->table );
	}
	
	/**
	 * 
	 * Checks the connection between a product and a category
	 * @param integer $product
	 * @param integer $category
	 */
	public function getRelation($product, $category) {
		$result = $this->db->select()->from($this->table)->where('local_id = ' . (int) $product . ' AND foreign_id = ' . (int) $category . '')->get()->row();
        $obj = FALSE;
        if ($result) {
            $obj = $this->from_array((array)$result);
        }
        return $obj;			
	}
}